package vista;
import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import modelo.Poliza;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VPoliza extends javax.swing.JFrame {
	private JPanel panPoliza;
	private JLabel lblTituloPoliza;
	private JTextField txtCodPlacaVehiculoPoliza;
	private JComboBox cmbTipo;
	private JLabel lblTipo;
	private JButton btnCancelarPoliza;
	private JButton btnSalirPoliza;
	private JButton btnEliminarPoliza;
	private JButton btnGuardarPoliza;
	private JButton btnRegistrarDetalle;
	private JButton btnBuscarPoliza;
	private JLabel lblCodPlacaVehiculo;
	private JTextField txtMontoTotalPoliza;
	private JLabel lblMontoTotalPoliza;
	private JTextField txtCodPoliza;
	private JLabel lblCodPoliza;
	private JSeparator sptTituloPoliza;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public VPoliza(String codigo) {
		super("Poliza");
		initGUI();
		this.txtCodPoliza.setText(codigo);
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
				panPoliza = new JPanel();
				getContentPane().add(panPoliza, BorderLayout.CENTER);
				panPoliza.setPreferredSize(new java.awt.Dimension(884, 443));
				panPoliza.setLayout(null);
				panPoliza.setFont(new java.awt.Font("Bitstream Charter",1,14));
				panPoliza.setBackground(new java.awt.Color(17,139,235));
				{
					sptTituloPoliza = new JSeparator();
					panPoliza.add(sptTituloPoliza);
					sptTituloPoliza.setBounds(115, 53, 612, 32);
				}
				{
					lblTituloPoliza = new JLabel();
					panPoliza.add(lblTituloPoliza);
					lblTituloPoliza.setText("Información Poliza");
					lblTituloPoliza.setFont(new java.awt.Font("Andika Basic",1,18));
					lblTituloPoliza.setBounds(310, 12, 218, 29);
				}
				{
					lblCodPoliza = new JLabel();
					panPoliza.add(lblCodPoliza);
					lblCodPoliza.setText("Código Poliza:");
					lblCodPoliza.setBounds(66, 138, 134, 23);
					lblCodPoliza.setFont(new java.awt.Font("Andika Basic",0,14));
				}
				{
					txtCodPoliza = new JTextField();
					panPoliza.add(txtCodPoliza);
					txtCodPoliza.setBounds(238, 137, 108, 26);
				}
				{
					lblMontoTotalPoliza = new JLabel();
					panPoliza.add(lblMontoTotalPoliza);
					lblMontoTotalPoliza.setText("Monto Poliza:");
					lblMontoTotalPoliza.setBounds(66, 228, 139, 23);
					lblMontoTotalPoliza.setFont(new java.awt.Font("Andika Basic",0,14));
				}
				{
					txtMontoTotalPoliza = new JTextField();
					panPoliza.add(txtMontoTotalPoliza);
					txtMontoTotalPoliza.setBounds(238, 227, 108, 26);
				}
				{
					lblCodPlacaVehiculo = new JLabel();
					panPoliza.add(lblCodPlacaVehiculo);
					lblCodPlacaVehiculo.setText("Código Placa Vehiculo Poliza:");
					lblCodPlacaVehiculo.setBounds(66, 273, 220, 34);
					lblCodPlacaVehiculo.setFont(new java.awt.Font("Andika Basic",0,14));
				}
				{
					txtCodPlacaVehiculoPoliza = new JTextField();
					panPoliza.add(txtCodPlacaVehiculoPoliza);
					txtCodPlacaVehiculoPoliza.setBounds(298, 277, 108, 26);
				}
				{
					btnBuscarPoliza = new JButton();
					panPoliza.add(btnBuscarPoliza);
					btnBuscarPoliza.setText("Buscar");
					btnBuscarPoliza.setBounds(445, 131, 103, 39);
					btnBuscarPoliza.setBackground(new java.awt.Color(165,42,42));
				}
				{
					btnRegistrarDetalle = new JButton();
					panPoliza.add(btnRegistrarDetalle);
					btnRegistrarDetalle.setText("Registrar Detalle Poliza");
					btnRegistrarDetalle.setBounds(52, 361, 207, 43);
					btnRegistrarDetalle.setBackground(new java.awt.Color(165,42,42));
				}
				{
					btnGuardarPoliza = new JButton();
					panPoliza.add(btnGuardarPoliza);
					btnGuardarPoliza.setText("Guardar");
					btnGuardarPoliza.setBounds(293, 361, 114, 44);
					btnGuardarPoliza.setBackground(new java.awt.Color(173,216,230));
				}
				{
					btnEliminarPoliza = new JButton();
					panPoliza.add(btnEliminarPoliza);
					btnEliminarPoliza.setText("Eliminar");
					btnEliminarPoliza.setBounds(452, 360, 101, 45);
					btnEliminarPoliza.setBackground(new java.awt.Color(173,216,230));
				}
				{
					btnSalirPoliza = new JButton();
					panPoliza.add(btnSalirPoliza);
					btnSalirPoliza.setText("Salir");
					btnSalirPoliza.setBounds(751, 360, 92, 45);
					btnSalirPoliza.setBackground(new java.awt.Color(173,216,230));
				}
				{
					btnCancelarPoliza = new JButton();
					panPoliza.add(btnCancelarPoliza);
					btnCancelarPoliza.setText("Cancelar");
					btnCancelarPoliza.setBounds(592, 362, 111, 42);
					btnCancelarPoliza.setBackground(new java.awt.Color(173,216,230));
				}
				{
					lblTipo = new JLabel();
					panPoliza.add(lblTipo);
					lblTipo.setText("Tipo:");
					lblTipo.setFont(new java.awt.Font("Andika Basic",0,14));
					lblTipo.setBounds(115, 183, 67, 23);
				}
				{
					ComboBoxModel cmbTipoModel = 
							new DefaultComboBoxModel(
									new String[] { "RCV", "CCA" });
					cmbTipo = new JComboBox();
					panPoliza.add(cmbTipo);
					cmbTipo.setModel(cmbTipoModel);
					cmbTipo.setBounds(231, 183, 108, 26);
				}
			}
			pack();
			this.setSize(898, 457);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

	public void addListener(ActionListener actionListener) {
		this.btnBuscarPoliza.addActionListener(actionListener);
		this.btnCancelarPoliza.addActionListener(actionListener);
		this.btnEliminarPoliza.addActionListener(actionListener);
		this.btnGuardarPoliza.addActionListener(actionListener);
		this.btnSalirPoliza.addActionListener(actionListener);
		this.btnRegistrarDetalle.addActionListener(actionListener);
	}
	
	public void limpiar(){
		this.txtCodPlacaVehiculoPoliza.setText("");
		this.txtCodPoliza.setText("");
		this.txtMontoTotalPoliza.setText("");
		this.btnGuardarPoliza.setText("Guardar");
		this.txtCodPoliza.setEditable(true);
	}
	
	public void bloquearBuscar(){
		this.btnGuardarPoliza.setText("Modificar");
		this.txtCodPoliza.setEditable(false);
	}
	
	public boolean camposVacios(){
		if(this.txtCodPlacaVehiculoPoliza.getText().equals("") || this.txtCodPoliza.getText().equals("")||this.txtMontoTotalPoliza.getText().equals(""))
			return true;
		return false;
	}
		
	public void mostrarMensaje(String mensaje){
		JOptionPane.showMessageDialog(this, mensaje);
	}

	public String getStrMonto() {
		return this.txtMontoTotalPoliza.getText().trim();
	}
	
	public String getCodPoliza() {
		return this.txtCodPoliza.getText().trim();
	}
	
	public String getPlaca() {
		return this.txtCodPlacaVehiculoPoliza.getText().trim();
	}

	public void setCodigo(String codigo) {
		this.txtCodPoliza.setText(codigo);
		
	}
	public String getTipo() {
		return this.cmbTipo.getSelectedItem().toString();
	}

	public void setPoliza(String pol_cod, String pol_mt, String pol_pa, String pol_tipo) {
		this.txtCodPoliza.setText(pol_cod);
		this.txtMontoTotalPoliza.setText(pol_mt);
		this.txtCodPlacaVehiculoPoliza.setText(pol_pa);
		if(pol_tipo=="RCV") this.cmbTipo.setSelectedIndex(0);
		else this.cmbTipo.setSelectedIndex(1);
		
	}
	
	
}


